<template>
  <div>

   <el-table   :data="guanLi" border   style="width: 100%">
    <el-table-column prop="id" label="编号"   width="100">
    </el-table-column>
    <el-table-column  prop="name"  label="名称"    width="100">
    </el-table-column>
    <el-table-column  prop="first_letter"  label="品牌首字母">
    </el-table-column>
     <el-table-column  prop="sort"  label="排序">
    </el-table-column>
     <el-table-column  prop=" factory_status"  label="品牌制造商">
       <template slot-scope="scope">
          <el-switch
            v-model="scope.row.show_status"
            :active-value="1"
            :inactive-value="0"
          >
          </el-switch>
        </template>
    </el-table-column>
    <el-table-column  prop="show_status"  label="是否显示">
      <template slot-scope="scope">
          <el-switch
            v-model="scope.row.show_status"
            :active-value="1"
            :inactive-value="0"
          >
          </el-switch>
        </template>
    </el-table-column>
   
    <el-table-column  prop=""  label="相关">
    </el-table-column>
    <el-table-column  prop="address"  label="操作">
      <template slot-scope="scope">
          <el-button size="small" @click="editFun(scope.row.id)"
            >编辑</el-button
          >
          <el-button type="danger" size="small" @click="delFun(scope.row.id)"
            >删除</el-button
          >
        </template>

         
    </el-table-column>

  </el-table>
  <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="listGuan.pageNum"
      :page-sizes="[5, 10, 15, 20]"
      :page-size="listGuan.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
</template>

<script>
//import axios from "axios"
import { shangpingguanli,ShangChu} from "@/api/product";
export default {
  name:"brand",
  data:function(){
      return {
        guanLi:[],
        listGuan:{
          pageSize:10,
          pageNum:1,
        },
       total:0
      };
     
  },
   mounted(){
    this.getBrandList();

   },
     methods:{

        delFun(id){
      console.log("删除了",id);
       this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          ShangChu({id:id}).then((res)=>{
            console.log(res);
            if(res.type == "sussess"){
               this.$message({
            type: 'success',
            message: '删除成功!'
          });
           this.getBrandList();
            }
          
          })
         
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
   },
        handleSizeChange(val){
     console.log("修改每页显示的条数 触发了", val);
     this.listGuan.pageSize = val;
     this.listGuan.pageNum = 1;
     this.getBrandList();
   },
   handleCurrentChange(val){
     console.log("修改当前页的页码 触发了", val);
     this.listGuan.pageNum = val;
     this.getBrandList();
   },
  
    async getBrandList(){
    // const res = await shangpingguanli();
    //  console.log(res);
    //   this.guanLi = res.data;
      var res = await shangpingguanli(this.listGuan);
     
      this.guanLi = res.data;
      
      this.total = res.total;
       console.log(res)
    }
   },
   

  
    
  //  mounted(){
  //       axios.get("http://yinruifang.cn/index/Api/get_product_brand_pag").then((res)=>{
  //         console.log(res)
  //         this.guanLi = res.data.data
  //       })
  //     }
} 
</script>

<style>

</style>